﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ITAP.Core.Modelling.Primitives;
using ITAP.ShprossesBuilder.Modelling.Measurement;
using ITAP.ShprossesBuilder.Modelling.Components;

namespace ITAP.ShprossesBuilder.Utils
{
    public class PinHolesDistanceHelper
    {
        public static List<IEndedPrimitive> GetSpacerElementPinHolesDistances(SpacerElement spacerElement, DimensionType dimensionType)
        {
            List<IEndedPrimitive> result = new List<IEndedPrimitive>();
            foreach (IComponent connectedComponent in spacerElement.Parent.ConnectedComponents)
            {
                if (connectedComponent is SpacerConnector)
                {
                    SpacerConnector spacerConnector = connectedComponent as SpacerConnector;
                    if (spacerConnector.ConnectedSpacerElement == spacerElement)
                    {
                        Dimension dimension = DimensionFactory.CreatePinHoleDimension(connectedComponent as SpacerConnector, spacerElement, dimensionType, false);
                        result.Add(dimension.Primitive);
                    }
                }
            } 
            return result;
        }
    }
}
